<template>
  <div>
    <div class="rank_style">
      <label class="rank_label">管理员登录</label>
    </div>
    <div class="userName">
      <input type="text" placeholder="用户名" v-model="username">
    </div>
    <div class="pwd">
      <input type="text" placeholder="密码" password="true" v-model="password">
    </div>
    <div><br></div>
    <div>
      <button class="weui-btn" @click="toManagerHome">submit</button>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        stateCode: 0,
        username: '',
        password: ''
      }
    },
    methods: {
      toManagerHome () {
        this.$fly.get(this.$store.state.URL + '/studygo/managerLogin', {
          username: this.username,
          password: this.password
        })
          .then(response => {
            console.log(response)
            this.stateCode = response.data.code
            if (this.stateCode === 200) {
              wx.redirectTo({
                url: '/pages/manager-main/main'
              })
            }
          })
          .catch(function (error) {
            console.log(error)
            wx.showToast({
              title: '用户名或密码错误',
              icon: 'error',
              duration: 1000
            })
          })
        console.log(this.stateCode)
      }
    }
  }
</script>

<style>
  .Login {
    height: 100px;
  }

  .userName {
    height: 30px;
    width: 70%;
    margin-left: 15%;
    font-family: "华文楷体";
  }

  .pwd {
    height: 30px;
    width: 70%;
    margin-left: 15%;
    font-family: "华文楷体";
  }

  .weui-btn {
    width: 70%;
    background: dodgerblue;
    border-radius: 98rpx;
    color: #ffffff;
  }

  .rank_style {
    height: 50px;
    background: dodgerblue;
    align-items: center;
    position: relative;
    display: flex;
    justify-content: center;
    flex-direction: column;
  }

  .rank_label {
    align-items: center;
    position: center;
    font-family: "华文楷体";
    color: #ffffff;
    font-size: 20px;
  }
</style>
